import { ObjCreate } from "../common/ObjCreate";
import { TilePanel } from "../equipment/TilePanel";
import { LoginSevenDaysRender } from "./loginSevenDays/LoginSevenDaysRender";
import { ScrollPolicy } from "../../../../fl/controls/ScrollPolicy";
import { ImagesConst } from "../../resource/ImagesConst";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { ResFileConst } from "../../resource/ResFileConst";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { SAttribute } from "../../../../Message/Public/SAttribute";
import { LoginSevenDaysInfo } from "./loginSevenDays/LoginSevenDaysInfo";
import { Cache } from "../../cache/Cache";
import { LoadRewardConfig } from "../../resource/LoadRewardConfig";
import { DataProvider } from "../../../../fl/data/DataProvider";
type int = number;
//class LoginSevenDaysPanel
    
    export  class LoginSevenDaysPanel /* flash.display.Sprite */
    {
        constructor(arg1: int, arg2: int)
        {
            
            this._width = arg1;
            this._height = arg2;
            this.initView();
            return;
        }

        /* internal  */initView(): void
        {
            ObjCreate.createBg(0, 0, 690, 400, this);
            this._bg = ObjCreate.createBitmap("", 360, 114, this);
            this._bgII = ObjCreate.createBitmap("", 300, 28, this);
            this._itemsList = new TilePanel();
            this._itemsList.setSize(690, 400);
            this._itemsList.columnWidth = 686;
            this._itemsList.rowHeight = 57;
            this._itemsList.setStyle("cellRenderer", LoginSevenDaysRender);
            this._itemsList.move(0, 0);
            this._itemsList.horizontalScrollPolicy = ScrollPolicy.OFF;
            this._itemsList.verticalScrollPolicy = ScrollPolicy.OFF;
            this.addChild(this._itemsList);
            var loc1=0;
            while (loc1 < 6) 
            {
                ObjCreate.createBg(13, 57 + 57 * loc1, 260 + 38 * loc1, 2, this, ImagesConst.SplitLine);
                ++loc1;
            }
            LoaderHelp.addResCallBack(ResFileConst.LoginSevenDays, this.onLoadBmResource);
            return;
        }

        /* internal  */onLoadBmResource(): void
        {
            this._bg.bitmapData = GlobalClass.getBitmapData(ImagesConst.LoginSevenDays_bg2);
            this._bgII.bitmapData = GlobalClass.getBitmapData(ImagesConst.LoginSevenDays_bg3);
            return;
        }

        public updateData(arg1: SAttribute): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=null;
            var loc5=0;
            if (arg1) 
            {
                loc1 = [];
                loc2 = new Map<any, any> /* flash.utils.Dictionary */();
                loc2 = this.getDayState(arg1.valueStr);
                loc3 = arg1.valueStr.split(",").length;
                loc5 = 1;
                while (loc5 < loc3) 
                {
                    (loc4 = new LoginSevenDaysInfo()).career = Cache.instance.role.entityInfo.career;
                    loc4.codeArr = LoadRewardConfig.instance.getSevenDaysReward(loc5, Cache.instance.role.entityInfo.career);
                    loc4.curLoginDay = arg1.value;
                    loc4.states = loc2[loc5];
                    loc4.day = loc5;
                    loc1.push(loc4);
                    ++loc5;
                }
                this._itemsList.dataProvider = new DataProvider(loc1);
            }
            return;
        }

        /* internal  */getDayState(arg1: string): Map<any, any> /* flash.utils.Dictionary */
        {
            var loc4=0;
            var loc1=new Map<any, any> /* flash.utils.Dictionary */();
            var loc2=arg1.split("#");
            var loc3=[];
            var loc5=0;
            while (loc5 < loc2.length) 
            {
                loc3 = loc2[loc5].split(",");
                loc4 = int(loc3[0]);
                loc1[loc4] = int(loc3[1]);
                ++loc5;
            }
            return loc1;
        }

        public flyRewardToPack(arg1: int): void
        {
            var loc1;
            --loc1;
            if (this._itemsList && this._itemsList.getItemAt(loc1)) 
            {
                (this._itemsList.getItemAt(loc1) as LoginSevenDaysInfo).flyFlag = true;
                this._itemsList.dataProvider = this._itemsList.dataProvider;
            }
            return;
        }

        /* internal */ /* var */_width: int;

        /* internal */ /* var */_height: int;

        /* internal */ /* var */_itemsList: TilePanel;

        /* internal */ /* var */_bg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_bgII: Object /* flash.display.Bitmap */;
    }
